//
//  AXMyChildBearingPeriodVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/11.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXMyChildBearingPeriodVC.h"
#import "UIView+SDAutoLayout.h"
#import "DateTimePickerView.h"

@interface AXMyChildBearingPeriodVC ()<DateTimePickerViewDelegate>

@property (nonatomic, strong) DateTimePickerView *datePickerView;
@property (nonatomic , strong) UIButton *startBtn;
@property (nonatomic , strong) UIButton *endBtn;

@end

@implementation AXMyChildBearingPeriodVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupNavigationItems];
    self.view.backgroundColor = [UIColor whiteColor];
    [self creatView];
    
}

- (void)creatView {
    
    UILabel *syqLabel = [[UILabel alloc]init];
    syqLabel.text = @"生育期";
    syqLabel.font = FONT_FOURTEEN;
    syqLabel.textColor = COLOR_Gray;
    [self.view addSubview:syqLabel];
    
    syqLabel.sd_layout
    .leftSpaceToView(self.view, 10)
    .topSpaceToView(self.view,100)
    .widthIs(60)
    .heightIs(30);
    
    UIButton *btn1 = [[UIButton alloc]init];
    btn1.cornerRadius = 5;
    btn1.titleLabel.font = [UIFont systemFontOfSize:14];
    btn1.backgroundColor = [UIColor lightGrayColor];
    [btn1 setTitle:@"萌芽期" forState:UIControlStateNormal];
    [self.view addSubview:btn1];
    
    
     btn1.sd_layout
    .rightSpaceToView(self.view, 20)
    .topSpaceToView(self.view,100)
    .widthIs(100)
    .heightIs(30);
    
    
    UILabel *timeLabel = [[UILabel alloc]init];
    timeLabel.text = @"生育期历时";
    timeLabel.font = FONT_FOURTEEN;
    timeLabel.textColor = COLOR_Gray;
    [self.view addSubview:timeLabel];
    
     timeLabel.sd_layout
    .leftSpaceToView(self.view, 10)
    .topSpaceToView(syqLabel,20)
    .widthIs(100)
    .heightIs(30);
    
    self.startBtn = [[UIButton alloc]init];
    [self.startBtn addTarget:self action:@selector(startTime:) forControlEvents:UIControlEventTouchUpInside];
    self.startBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
    self.startBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.startBtn setTitleColor:COLOR_ORG forState:UIControlStateNormal];
    [self.startBtn setTitle:@"请选择开始时间" forState:UIControlStateNormal];
    [self.view addSubview:self.startBtn];
    
     self.startBtn.sd_layout
    .leftSpaceToView(timeLabel, 10)
    .topEqualToView(timeLabel)
    .widthIs((SCREEN_WIDTH-140)/2)
    .heightIs(30);
    
    
  self.endBtn = [[UIButton alloc]init];
    [self.endBtn addTarget:self action:@selector(startTime:) forControlEvents:UIControlEventTouchUpInside];
     self.endBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
    self.endBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.endBtn setTitleColor:COLOR_ORG forState:UIControlStateNormal];
    [self.endBtn setTitle:@"请选结束时间" forState:UIControlStateNormal];
    [self.view addSubview:self.endBtn];
    
    self.endBtn.sd_layout
    .leftSpaceToView(self.startBtn, 10)
    .topEqualToView(timeLabel)
    .widthRatioToView(self.startBtn, 1)
    .heightIs(30);
    
    
    
   
    
    
    UIButton *saveBtn = [[UIButton alloc]init];
    saveBtn.backgroundColor = COLOR_GREEN;
    saveBtn.cornerRadius = 5;
    [saveBtn setTitle:@"保存" forState:UIControlStateNormal];
    [saveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [saveBtn addTarget:self action:@selector(save:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:saveBtn];
    
    
    saveBtn.sd_layout
    .leftSpaceToView(self.view, 50)
    .topSpaceToView(self.endBtn, 50)
    .widthIs(SCREEN_WIDTH-100)
    .heightIs(30);
    
    
    
    
    
}

#pragma mark - action

- (void)startTime:(UIButton *)btn {
    
    DateTimePickerView *pickerView = [[DateTimePickerView alloc] init];
    self.datePickerView = pickerView;
    pickerView.delegate = self;
    pickerView.pickerViewMode = DatePickerViewDateTimeMode;
    [self.view addSubview:pickerView];
    [pickerView showDateTimePickerView];
    
}

- (void)endTime:(UIButton *)btn {
    
    DateTimePickerView *pickerView = [[DateTimePickerView alloc] init];
    self.datePickerView = pickerView;
    pickerView.delegate = self;
    pickerView.pickerViewMode = DatePickerViewDateTimeMode;
    [self.view addSubview:pickerView];
    [pickerView showDateTimePickerView];
}

- (void)save:(UIButton *)btn {
    
}

- (void)setupNavigationItems {
    
    /** 导航条左边的按钮 */
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 30, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    /** 搜索 */
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
    titleLabel.text = @"选泽生育期";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = FONT_FOURTEEN;
    titleLabel.textColor = [UIColor colorWithHex:0x29b566];
    self.navigationItem.titleView = titleLabel;
    
    
}

#pragma mark - Action

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}



#pragma mark - delegate

- (void)didClickFinishDateTimePickerView:(NSString *)date{

    [self.startBtn setTitle:date forState:UIControlStateNormal];
    [self.endBtn setTitle:date forState:UIControlStateNormal];

}


@end
